# -*- coding:UTF-8 -*-
"""
@Project : pythonProject
@File    : decorator_test.py
@IDE     : PyCharm
@Author  : WorldWind(1772830365@qq.com)
@Address : China - HeiLongjiang - Herbin
@Date    : 2025/7/15 下午3:49
"""
from highLevelPython.July15_class_code.decorators.decorator import checkUserLogin
from highLevelPython.July15_class_code.decorators.decorator import decorator


class WeiBo:
    def __init__(self):
        print(f'This is __init__ method. {self.get_class_name()} class startup')

    # 查看帖子内容,不需要登录
    def view(self):
        print('查看帖子内容')

    # 搜索帖子,不需要登录
    def search(self):
        print('搜索帖子内容,返回帖子列表')

    @decorator
    @checkUserLogin
    def post(self):
        # 检查调用这个方法的用户是不是登录了
        # 如果没有登录,报错,让用户登录
        print('发帖子功能')
        return '发帖子功能'

    @checkUserLogin
    def updateProfile(self):
        # 检查调用这个方法的用户是不是登录了
        # 如果没有登录,报错,让用户登录
        print('更新用户资料')

    @classmethod
    def get_class_name(cls):
        return cls.__name__

    def __del__(self):
        print(f'This is __del__ method. The {self.get_class_name()} class has been recycled')

if __name__ == '__main__':
    w = WeiBo()
    w.post()